#ifndef _GPS_LINEARIZE_H_
#define _GPS_LINEARIZE_H_
#include "common/macro.h"
#define to_radians(x) ( (x) * (M_PI / 180.0 ))
#define to_degrees(x) ( (x) * (180.0 / M_PI ))

struct gps_linearize_t {
  double lon0_deg, lat0_deg;
  double radius_ns, radius_ew;
};

class GPSCoordinateTool {
 public:
  ~GPSCoordinateTool() = default;
  GPSCoordinateTool() = default;
  void gps_linearize_init(const double ll_deg[2]);
  int gps_linearize_to_xy(const double ll_deg[2], double xy[2]);
  int gps_linearize_to_lat_lon(const double xy[2], double ll_deg[2]);
  int gps_linearize_to_lat_lon(const double x,const double y, double *lat,double *lon);
  void vRotationTransform(double *dxy, double *newy, double *transxy, double rota);
  void vRotationtoxy(double *dxy, double *newy, double rota);
  void Gloable2Relative(double *gloable, double *local, double *vehicle);
  void Relative2Gloable(double *local, double *gloable, double *vehicle);
  double DistancePoint2Point(double *point1,double *point2);
  double sq(double v);


 private:
  gps_linearize_t origin_;
  DECLARE_SINGLETON_WITHOUT_CONSTRUCTOR(GPSCoordinateTool);

};

#endif
